<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组开头的删除和添加</title>
</head>
<body>
    <script>
        // shift()方法用于删除数组的第一个元素，并返回该元素。会改变元素组。
        var arr = [1,2,3,4,5,6];
        var a = arr.shift();    //1
        console.log(a);
        console.log(arr);   //[2,3,4,5,6]

        // unshift()方法用于向数组的开头添加一个或多个元素，并返回新数组的长度。会改变原数组。会改变元素组。
        var arr1 = [1,2,3,4,5,6];
        var b = arr1.unshift(11,0);
        console.log(b);   //8
        console.log(arr1);   //[11,0,1,2,3,4,5,6]
    </script>
</body>
</html>